<template>
	<view class="content" >
		<view class="viewG">
			<view class="list1 Line" >
				<view class="lab1">中文</view>
				<label class="radio" >
					<radio value="1" color="red" :checked="isEn  == false" @click="btnChangeClick('1')"/>
				</label>
			</view>
			<view class="list1 radiusB">
				<view class="lab1">English</view>
				<label class="radio" >
					<radio value="1" color="red" :checked="isEn" @click="btnChangeClick('2')"/>
				</label>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				isEn:false  //中文false  英文true
			}
		},
		onLoad() {
			let currentLang = uni.getStorageSync('CURRENT_LANG')
			if (currentLang === 'en') {
			  this.isEn = true
			} else {
			  this.isEn = false
			}
		},
		methods: {
			btnChangeClick(key){
				if (key == '1' && this.isEn) {
					
					
					this.isEn = false
					getApp().globalData._i18n.locale = 'zh-CN'
					uni.setStorageSync('CURRENT_LANG', 'zh-CN')
					uni.showToast({
						icon:'loading',
						title:'正在努力切换中'
					})
					
					setTimeout(()=>{
						uni.switchTab({
							url:'../index/index'
						})
					},1500)
					
					
						
					
				} else if (key == '2' && this.isEn == false) {
				
					this.isEn  = true
					getApp().globalData._i18n.locale = 'en'
					uni.setStorageSync('CURRENT_LANG', 'en')
					uni.showToast({
						icon:'loading',
						title:'Try to switch'
					},1500)
					
					setTimeout(()=>{
						uni.switchTab({
							url:'../index/index'
						})
					},1500)
						
					
				}
			}
		}
	}
</script>

<style>
page{
		background-color: #f2f2f2;
		
}
.viewG{
	background-color: #fff;
	margin-top: 20rpx;
	
}
 .list1{
		
	padding: 0rpx 30rpx;
	display: flex;
	flex-direction: row;
	justify-content: space-between;
	align-items: center;
	height: 110rpx;
}
.Line{
	
	border-bottom: 1rpx solid #f2f2f2;

}
.lab1{
	color: #333;
	font-size: 34rpx;
	font-weight: 200;
}

</style>
